package mathive.server.persistant;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Vector;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Test {
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
	
	@Persistent
    private String name;
	
	@Persistent
    private int score;
	
	@Persistent
    private List<GamesData> games;
	
	@Persistent
	private Vector<String> statistics;
	
	@Persistent
    private Key creator;
	
	@Persistent
    private Date created;
	
	public Test(String name, int score, List<GamesData> games, Key creator) {
		this.name = name;
		this.score = score;
		this.games = games;
		this.creator = creator;
		this.created = new Date();
		this.statistics = new Vector<String>();
		this.statistics.add(name);
    }
    
    public Key getKey() {
        return key;
    }
    
    public String getName() {
        return name;
    }
	
	public int getScore() {
        return score;
    }
    
    public List<GamesData> getGames() {
        return games;
    }
    
    public int nrOfGames() {
    	return games.size();
    }
    
    public Key getCreator() {
        return creator;
    }
    
    public Date getDateCreated() {
        return created;
    }
    
    public List<String> getStatistics(){

    	return statistics;
    }
    
    public void addStatistics(String username, String stats){		
		SimpleDateFormat formatter;
		formatter = new SimpleDateFormat("d MMMMM yyyy");
    	String date = formatter.format(new Date());
		
		String string = date + " " + username + " " + stats;

		this.statistics.add(string);
    }
}
